package java111;

import java.util.Arrays;
import java.util.Scanner;

public class Day8 {
    // https://www.nowcoder.com/questionTerminal/22948c2cad484e0291350abad86136c3
    public static void main1(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNextInt()) { // 注意 while 处理多个 case
            int a = in.nextInt();
            int b = in.nextInt();
            if (a > b) {
                solution(a, b);
            } else if (a == b) {
                System.out.println(a);
            } else {
                solution(b, a);
            }
        }
    }

    public static void solution(int max, int min) {
        long tmp = (long) max * min;
        long res = tmp;
        while (tmp >= min) {
            if (tmp / min == 0) {
                res = Math.min(res, tmp);
            }
            tmp -= max;
        }
        System.out.println(res);
    }

    public static void main2(String[] args) {
        Scanner in = new Scanner(System.in);
        while (in.hasNextInt()) {
            int a = in.nextInt();
            int b = in.nextInt();
            System.out.println(a * b / func(a, b));
            // 最小公倍数等于a * b / 最大公约数
        }
    }

    // 辗转相除法求最大公约数
    public static int func(int a, int b) {
        if (b == 0) {
            return a;
        }
        return func(b, a % b);
    }


    // https://www.nowcoder.com/practice/eac1c953170243338f941959146ac4bf?tpId=196&tqId=37143&ru=/exam/oj
    public static void main3(String[] args) {
        int[] arr = new int[]{100, 4, 200, 1, 3, 2};
        System.out.println(MLS(arr));
    }

    public static int MLS(int[] arr) {
        // write code here
        Arrays.sort(arr);
        int res = 1;
        int[] dp = new int[arr.length];
        dp[0] = 1;
        for (int i = 1; i < dp.length; i++) {
            dp[i] = 1;
            if ((arr[i] - arr[i - 1]) == 1) {
                dp[i] = dp[i - 1] + 1;
            }
            res = Math.max(res, dp[i]);
        }
        return res;
    }



    //https://www.nowcoder.com/practice/9740ce2df0a04399a5ade1927d34c1e1?tpId=230&tqId=38954&ru=/exam/oj
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNextInt()) { // 注意 while 处理多个 case
            int n = in.nextInt();
            int m = in.nextInt();
            in.nextLine();
            String[] arr = new String[n];
            for(int i = 0; i < n; i++){
                arr[i] = in.nextLine();
            }
            int[][] dp = new int[n+1][m+1];
            int res = 0;
            for(int i = 1; i < n+1; i++){
                for(int j = 1; j < m+1; j++){
                    char c = arr[i-1].charAt(j-1);
                    dp[i][j] = Math.max(dp[i-1][j], dp[i][j-1]) + maxValue(c);
                    res = Math.max(res, dp[i][j]);
                }
            }
            System.out.println(res);
        }
    }
    public static int maxValue(char c){
        switch(c){
            case 'l': return 4;
            case 'o': return 3;
            case 'v': return 2;
            case 'e': return 1;
            default : return 0;
        }
    }
}
